from dao import CronJob, start
from google.appengine.ext.webapp.util import run_wsgi_app
from gui import GUIQuanLyNhanVien, GUIChiTieuKinhDoanh, GUIHoaHongNhanVien, \
    GUIQuanLyKhachHang, GUIDonHang, GUIQuanLyHangHoa, GUIQuanLyGiaBan, \
    GUIQuanLyDonHang, GUIHomePage, GUIPhanQuyen, GUIHangSanXuatHomNay, \
    GUIGiaoHangHomNay, GUIBaoCaoDoanhThu, GUIQuanLyCongNo, GUIQuanLyThuChi,\
    GUIError
import jinja2
import os
import webapp2


urls = [('/quanlynhanvien/json/', GUIQuanLyNhanVien.JsonRequestHandler),
        ('/quanlynhanvien/', GUIQuanLyNhanVien.GuiQuanLyNhanVien),
        ('/chitieukinhdoanh/', GUIChiTieuKinhDoanh.GuiChiTieuKinhDoanh),
        ('/chitieukinhdoanh/json/', GUIChiTieuKinhDoanh.JsonRequestHandler),
        ('/hoahongnhanvien/', GUIHoaHongNhanVien.GuiHoaHongNhanVien),
        ('/hoahongnhanvien/json/', GUIHoaHongNhanVien.JsonRequestHandler),
        ('/quanlykhachhang/', GUIQuanLyKhachHang.GuiQuanLyKhachHang),
        ('/quanlykhachhang/json/', GUIQuanLyKhachHang.JsonRequestHandler),
        ('/donhang/', GUIDonHang.GuiDonHang),
        ('/donhang/json/', GUIDonHang.JsonRequestHandler),
        ('/quanlyhanghoa/', GUIQuanLyHangHoa.GuiQuanLyHangHoa),
        ('/quanlyhanghoa/json/', GUIQuanLyHangHoa.JsonRequestHandler),
        ('/quanlygiaban/', GUIQuanLyGiaBan.GuiQuanLyGiaBan),
        ('/quanlygiaban/json/', GUIQuanLyGiaBan.JsonRequestHandler),
        ('/quanlydonhang/', GUIQuanLyDonHang.GuiQuanLyDonHang),
        ('/quanlydonhang/json/', GUIQuanLyDonHang.JsonRequestHandler),
        ('/phanquyen/', GUIPhanQuyen.GuiPhanQuyen),
        ('/phanquyen/json/', GUIPhanQuyen.JsonRequestHandler),
        ('/hangsanxuathomnay/', GUIHangSanXuatHomNay.GuiHangSanXuatHomNay),
        ('/hangsanxuathomnay/json/', GUIHangSanXuatHomNay.JsonRequestHandler),
        ('/giaohanghomnay/', GUIGiaoHangHomNay.GuiGiaoHangHomNay),
        ('/giaohanghomnay/json/', GUIGiaoHangHomNay.JsonRequestHandler),
        
        ('/baocaodoanhthu/', GUIBaoCaoDoanhThu.GuiBaoCaoDoanhThu),
        ('/baocaodoanhthu/json/', GUIBaoCaoDoanhThu.JsonRequestHandler),
        
        ('/quanlycongno/', GUIQuanLyCongNo.GuiQuanLyCongNo),
        ('/quanlycongno/json/', GUIQuanLyCongNo.JsonRequestHandler),
        
        ('/quanlythuchi/', GUIQuanLyThuChi.GuiQuanLyThuChi),
        ('/quanlythuchi/json/', GUIQuanLyThuChi.JsonRequestHandler),
        
        ('/', GUIHomePage.GUIHomePage),
        ('', GUIHomePage.GUIHomePage),
        ('/tasks/cron/', CronJob.OrderStatusHandler),
        ('/start/', start.Start),
        ('/error/', GUIError.GuiError)
        ]
application = webapp2.WSGIApplication(urls, debug=True)

jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
